package com.ruoyi.videoMonitor.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.videoMonitor.domain.VideoRecord;
import com.ruoyi.videoMonitor.service.IVideoRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监控视频Controller
 * 
 * @author Leo
 * @date 2024-07-12
 */
@RestController
@RequestMapping("/videoMonitor/video")
public class VideoRecordController extends BaseController
{
    @Autowired
    private IVideoRecordService videoRecordService;

    /**
     * 查询监控视频列表
     */
    @PreAuthorize("@ss.hasPermi('videoMonitor:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoRecord videoRecord)
    {
        startPage();
        List<VideoRecord> list = videoRecordService.selectVideoRecordList(videoRecord);
        return getDataTable(list);
    }

    /**
     * 导出监控视频列表
     */
    @PreAuthorize("@ss.hasPermi('videoMonitor:video:export')")
    @Log(title = "监控视频", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VideoRecord videoRecord)
    {
        List<VideoRecord> list = videoRecordService.selectVideoRecordList(videoRecord);
        ExcelUtil<VideoRecord> util = new ExcelUtil<VideoRecord>(VideoRecord.class);
        return util.exportExcel(list, "监控视频数据");
    }

    /**
     * 获取监控视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('videoMonitor:video:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(videoRecordService.selectVideoRecordById(id));
    }

    /**
     * 新增监控视频
     */
//    @PreAuthorize("@ss.hasPermi('videoMonitor:video:add')")
    @Log(title = "监控视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoRecord videoRecord)
    {
        return toAjax(videoRecordService.insertVideoRecord(videoRecord));
    }

    /**
     * 修改监控视频
     */
    @PreAuthorize("@ss.hasPermi('videoMonitor:video:edit')")
    @Log(title = "监控视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoRecord videoRecord)
    {
        return toAjax(videoRecordService.updateVideoRecord(videoRecord));
    }
//
//    /**
//     * 删除监控视频
//     */
//    @PreAuthorize("@ss.hasPermi('videoMonitor:video:remove')")
//    @Log(title = "监控视频", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(videoRecordService.deleteVideoRecordByIds(ids));
//    }
}
